﻿using System;
using UnityEngine;

public class SetPositionToMouseRayHit : MonoBehaviour
{
    private Camera mainCam;
    private Transform tsm;

    private void Awake()
    {
        this.tsm = base.transform;
    }

    private void LateUpdate()
    {
        RaycastHit hit;
        if (this.mainCam == null)
        {
            this.mainCam = Camera.main;
        }
        if ((this.mainCam != null) && Physics.Raycast(this.mainCam.ScreenPointToRay(Input.mousePosition), out hit))
        {
            this.tsm.position = hit.point;
        }
    }
}

